Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes copy code not working for modal due to no focus in Modal #22366

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

AltamashShaikh
Copy link
Contributor

Description:

Fixes copy code not working for modal due to no focus in Modal, during development of matomo-org/tag-manager#814, it was noticed that clipboard remains empty as there was no focus to textarea.
Fixes: #PG-3520

Review

@AltamashShaikh AltamashShaikh added the Needs Review PRs that need a code review label Jul 3, 2024
@AltamashShaikh AltamashShaikh requested a review from a team July 3, 2024 05:13
@sgiehl sgiehl added this to the 5.2.0 milestone Jul 3, 2024
@sgiehl sgiehl merged commit f8d82ef into 5.x-dev Jul 3, 2024
22 of 25 checks passed
@sgiehl sgiehl deleted the PG-3520-fix-copy-button branch July 3, 2024 07:28
@@ -26,6 +26,7 @@ function onClickHandler(pre: HTMLElement) {
textarea.style.left = '-9999px';
document.body.appendChild(textarea);
textarea.select();
textarea.focus();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense to focus first and then select? Just purely from the perspective of what happens when a user selects text in a textarea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michalkleiner No preference over it as it needs focus just before document.execCommand('copy'); is executed for it to work always, so added there and won't make any harm I believe even if change to what you are suggesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants